﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserEdit.aspx.cs" MasterPageFile="~/Layouts/Form.Master" Inherits="Bingosoft.WebApp.Modules.SecurityConsole.User.UserEdit" %>
<%@ Import Namespace="Bingosoft.Modules.SecurityConsole.Common.Helper" %>
<%@ Import Namespace="Bingosoft.Web.Utils" %>

<asp:Content ContentPlaceHolderID="head" ID="idFormTitle" runat="server">
     <title><%=Request["title"]%></title>
     <web:Script ID="Script2" src="~/Widgets/core/inputpro/ui.inputpro.js" runat="server" />
     <web:Script ID="Script1" src="~/Modules/SecurityConsole/Common/FunctionControl/CategorySelect/CategorySelectControl.js" runat="server" />
</asp:Content>
<asp:Content ContentPlaceHolderID="Content" ID="idFormMain" runat="server">
<script type="text/javascript">
    var Global = {};
    Global.contextPath = '<%= RequestHelper.GetContextPath(Request) %>';
</script>
    <!-- 页面头部 -->
	<div class="header">
	    <h1><%=Request["title"]%></h1>
	</div>

    <web:SmartFormView ID="SmartFormView1" runat="server" DataKeyNames="Id" DataSourceID="SmartDataSource1"
        Width="100%">        
        <InsertItemTemplate></InsertItemTemplate>
        <EditItemTemplate></EditItemTemplate>
        <ItemTemplate>
            <asp:HiddenField ID='Id' runat='server' Value='<%# Bind("Id") %>' />
          <div>
            <table cellpadding='2' cellspacing='1' width='100%' class="formitem">
            <caption><%=Request["title"]%></caption>
                <tr>
                    <th width="15%">                        
                        用户名称：<font color='red'>*</font>
                    </th>
                    <td width="35%">
                        <asp:TextBox ID="Name" runat="server" Text='<%# Bind("Name") %>' Width='80%' validator="required,length[1,50]"></asp:TextBox>                        
                    </td>
                    <th width="15%" style=" display:none;">    
                        所属组织：<font color='red'>*<ont>
                    </th>
                    <td width="35%" style=" display:none;">
                        <asp:HiddenField ID="OrgId" runat="server" Value='<%# Bind("OrgId") %>' />
                        <asp:TextBox ID='OrgName' runat='server' Text='<%# Bind("OrgName") %>' Width='80%' ReadOnly="true"></asp:TextBox>
                        <img runat="server" src="~/Images/ico_preview.gif" onclick="selectClz()" style="cursor:pointer"/>
                    </td>
                    <th></th>
                    <td></td>
                   <%-- <th width="15%">    
                        用户类型：
                    </th>
                    <td width="35%">
                        <web:DataDictionaryDropDownList ID='Type' runat='server' DictionaryCode='UserType' SelectedValue='<%# Bind("Type") %>' Width='80%'>
                            <asp:ListItem Value="" Text=""></asp:ListItem>
                        </web:DataDictionaryDropDownList>
                    </td>--%>
                </tr>
               
                <tr>
                    <th>
                        登录帐号：<font color='red'>*</font>
                    </th>
                    <td>
                        <asp:TextBox ID='LoginId' runat='server' Text='<%# Bind("LoginId") %>' validator="required" Width='80%'></asp:TextBox>
                    </td>
                    <th>
                        用户性别：<font color='red'>*</font>
                    </th>
                    <td>
                        <web:DataDictionaryDropDownList ID='Sex' runat='server' DictionaryCode='Sex' SelectedValue='<%# Bind("Sex") %>' Width='80%' validator="required">
                            <asp:ListItem Value="" Text=""></asp:ListItem>
                        </web:DataDictionaryDropDownList>
                    </td>
                </tr>     
                <%if (this.SmartFormView1.IsInsert())
                  {%>
                 <tr>
                    <th>
                        登录密码：<font color='red'>*</font>
                    </th>
                    <td>
                        <asp:TextBox ID='Password' runat='server' Text='' TextMode="Password" validator="required[密码不能为空],func[checkPassword]" Width='80%'></asp:TextBox>
                    </td>
                    <th>
                        确认密码：<font color='red'>*</font>
                    </th>
                    <td>
                        <asp:TextBox ID='ConfirmPassword' runat='server' TextMode="Password" Text='' validator="required[密码不能为空],func[checkPassword]" Width='80%'></asp:TextBox>
                    </td>
                </tr>     
                <%
                  }%>
                  <tr>
                    <th>                        
                        邮箱地址：
                    </th>
                    <td>
                        <asp:TextBox ID="Email" runat="server" Text='<%# Bind("Email") %>' Width='80%' validator="email" MaxLength="50"></asp:TextBox>                        
                    </td>
                    <th>
                        手机号码：
                    </th>
                    <td>
                        <asp:TextBox ID='MobilePhone' runat='server' Text='<%# Bind("MobilePhone") %>' Width='80%' validator="mobile" MaxLength="30"></asp:TextBox>
                    </td>
                </tr>                   
            </table>
        </div>
        </ItemTemplate>
    </web:SmartFormView>
    
    <web:SmartSqlDataSource ID="SmartDataSource1" runat="server" SelectCommand="user.get.user.by.Id" SelectCommandAutoPageWrap="false">
    </web:SmartSqlDataSource>

    <!-- 页脚区域 -->
	<div class="footer">
		<asp:Button ID="Button1" runat="server" Text="确定" 
            OnClientClick="return validateForm();" onclick="SaveOrUpdateUser"/>        
        <asp:Button ID="CloseButton2" runat="server" Text="关闭" OnClientClick="return closeDialog();" />        
	</div>
    

    <script type="text/javascript">
        function selectClz() {
            process({
                sqlId: 'organization.firstFloor.tree',
                childSqlId: 'organization.getChildren',
                title: '组织机构选择',
                idField: '<%=ControlHelper.FindControl(this.SmartFormView1, "OrgId").ClientID %>',
                nameField: '<%=ControlHelper.FindControl(this.SmartFormView1, "OrgName").ClientID %>',
                isAsyn: 'true',
                params: {}
            });
        }

         function checkPassword() {
            var password = $('#<%=ControlHelper.FindControl(this.SmartFormView1, "Password").ClientID %>').val();
            var confirmPassword = $('#<%=ControlHelper.FindControl(this.SmartFormView1, "ConfirmPassword").ClientID %>').val();
            if(password == confirmPassword && password != "" ){
                return {isError:false,errorInfo:""};
            }

            return {isError:true,errorInfo:"密码与确认密码要保持一致!"};
        }
        
    </script>    

</asp:Content>

    
